package com.example.mybiadushoujiweishi.activity.acivitys.fragments;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.example.mybiadushoujiweishi.R;
import com.example.mybiadushoujiweishi.activity.acivitys.adapter.AddContactsAdapter;
import com.example.mybiadushoujiweishi.activity.acivitys.entity.Contact;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2017/6/7 0007.
 */

public class SelectContactFragment extends Fragmentbase {
    @BindView(R.id.selectd_catact_recyclerview)
    RecyclerView selectdCatactRecyclerview;
    List<Contact> list=new ArrayList<Contact>();
    AddContactsAdapter addContactsAdapter;
    Unbinder unbinder;

    @Override
    public int getXml() {
        return R.layout.select_contact_fragment;
    }

    @Override
    public void initView() {


//        输入框中输入了什么内容


    }

    @Override
    public void initData() {
        selectdCatactRecyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
        TextView textView= (TextView) getActivity().findViewById(R.id.chosecontactnumber);
        addContactsAdapter = new AddContactsAdapter(list,textView);

        selectdCatactRecyclerview.setAdapter(addContactsAdapter);
    }

    public void getSelectContact(List<Contact> contact){
        list.clear();
        list.addAll(contact);
        if (list!=null) {

            addContactsAdapter.notifyDataSetChanged();
        }
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {

        super.onDestroyView();
        unbinder.unbind();
    }
}
